﻿
@{
    ViewBag.Title = "会员特权";
}
@section CSS{
    <link href="~/Content/css/layerui/layui.css" rel="stylesheet" />
    <link href="~/Content/js/UploadImg/css/webuploader.css" rel="stylesheet" />
    <link href="~/Content/js/UploadImg/css/goodsupload.css" rel="stylesheet" />
}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <section class="content-header">
        <h1>
            @ViewBag.text
            <small>会员特权</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">系统管理</a></li>
            <li><a href="/SystemSetting/UserRule">会员特权列表</a></li>
            <li class="active">@ViewBag.text 会员特权</li>
        </ol>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-body">
                        <div class="ibox float-e-margins">

                            <div class="ibox float-e-margins">
                                <div class="ibox-content">
                                    <form class="form-horizontal" id="form-add" method="post" action="/SystemSetting/AddorEditUserRule">
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">名称 <span style="color:red;">*</span>：</label>
                                            <div class="col-sm-10">
                                                <input type="text" name="title" id="title" value="" class="form-control" placeholder="名称" required="" aria-required="true" />
                                                <span class="help-block m-b-none"></span>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">副名称 <span style="color:red;">*</span>：</label>
                                            <div class="col-sm-10">
                                                <input type="text" name="title_sub" id="title_sub" value="" class="form-control" placeholder="副名称" required="" aria-required="true" />
                                                <span class="help-block m-b-none"></span>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">标题 <span style="color:red;">*</span>：</label>
                                            <div class="col-sm-10">
                                                <input type="text" name="subhead" id="subhead" value="" class="form-control" placeholder="标题" required="" aria-required="true" />
                                                <span class="help-block m-b-none"></span>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">简介：</label>
                                            <div class="col-sm-10">
                                                <input type="text" name="summary" id="summary" maxlength="250" class="form-control" placeholder="请输入简介" value="">
                                                <span class="help-block m-b-none">最多不超过250个字</span>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">上传图标 <span style="color:red;">*</span>：</label>
                                            <div class="col-sm-3">
                                                <div class="layui-upload">
                                                    <button type="button" class="layui-btn" id="test1">图标</button><input class="layui-upload-file" type="file" accept="undefined" name="file">
                                                    <div class="layui-upload-list">
                                                        <img class="layui-upload-img" id="ico_img" onclick="javascript:imgzoom(this.id)" style="width: 50px; height: 50px; cursor: pointer">
                                                        <p id="demoText1"></p>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-sm-3">
                                                <div class="layui-upload">
                                                    <button type="button" class="layui-btn" id="test2">选中图标</button><input class="layui-upload-file" type="file" accept="undefined" name="file">
                                                    <div class="layui-upload-list">
                                                        <img class="layui-upload-img" id="selected_ico_img" onclick="javascript:imgzoom(this.id)" style="width: 50px; height: 50px; cursor: pointer">
                                                        <p id="demoText2"></p>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">介绍图 <span style="color:red;">*</span>：</label>
                                            <div class="col-sm-3">
                                                <div class="layui-upload">
                                                    <button type="button" class="layui-btn" id="test3">上传介绍图</button><input class="layui-upload-file" type="file" accept="undefined" name="file">
                                                    <div class="layui-upload-list">
                                                        <img class="layui-upload-img" id="picture_url_img" onclick="javascript:imgzoom(this.id)" style="width: 210px; height: 70px; cursor: pointer">
                                                        <p id="demoText3"></p>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">排序：</label>
                                            <div class="col-sm-10">
                                                <input type="text" name="sort" id="sort" value="99" class="form-control" placeholder="排序" />
                                                <span class="help-block m-b-none"></span>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">描述：</label>
                                            <div class="col-sm-10">
                                                <textarea name="content" id="content" class="form-control" placeholder="请输入描述" rows="4"></textarea>
                                                <span class="help-block m-b-none"></span>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">内容图片：</label>
                                            <div class="col-sm-10">
                                                <div id="uploader1" class="goodsuploader">
                                                    <div class="item_container">
                                                        <div class="queueList" id="queueList1">
                                                            <div id="dndArea1" class="placeholder">
                                                                <div id="filePicker11" style="line-height:12px;margin-bottom:5px;"></div>
                                                            </div>
                                                            @*<ul id="filelist" class="filelist"></ul>*@
                                                        </div>
                                                    </div>
                                                    <div class="statusBar" id="statusBar1" style="display:none;">
                                                        <div class="progress" id="progress1">
                                                            <span class="text">0%</span>
                                                            <span class="percentage"></span>
                                                        </div><div class="info" id="info1"></div>
                                                        <div class="btns">
                                                            <div id="filePicker12"></div><div class="uploadBtn" id="uploadBtn1">开始上传</div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <span class="help-block m-b-none">最多可上传 30 张图片，每张大小不超过 1 M</span>
                                            </div>
                                        </div>
                                        <input type="hidden" id="id" value="0" name="id">
                                        <input type="hidden" id="picture_url" value="" name="picture_url">
                                        <input type="hidden" id="ico" value="" name="ico">
                                        <input type="hidden" id="selected_ico" value="" name="selected_ico">
                                        <div class="form-group">
                                            <div class="col-sm-4 col-sm-offset-2">
                                                <button class="btn btn-primary" onclick="SaveUserRule()" type="button">保存信息</button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

</div>

@section JS{
    <script src="~/Content/js/jquery.form.js"></script>
    <script src="~/Content/plugins/validate/jquery.validate.min.js"></script>
    <script src="~/Content/plugins/validate/messages_zh.min.js"></script>
    <script src="~/Content/js/UploadImg/js/webuploader.js"></script>
    <script src="~/Content/js/UploadImg/js/jquery.sortable.js"></script>
    <script>
        var s_id=0;
    </script>
    <script src="~/Content/js/UploadImg/js/userRuleContentUpload.js"></script>
    <script type="text/javascript">
        var _id = "@ViewBag.id";
        $(function () {
            if (_id != undefined && _id!="0")
            {getinfo(_id);}
        });
        //后期可重构一个方法
        layui.use('upload', function () {
            var $ = layui.jquery
                , upload = layui.upload;
            //普通图片上传
            var uploadInst = upload.render({
                elem: '#test1'
                , url: domain + "/tools/UploadPCImage?type=UserRule"
                ,size:1024
                , before: function (obj) {
                    //预读本地文件示例，不支持ie8
                    obj.preview(function (index, file, result) {
                        $('#ico_img').attr('src', result); //图片链接（base64）

                    });
                },

                done: function (res) {
                    $('#ico_img').attr('src', domain + res.info);
                    $('#ico').val(sqlImgdomain+res.info);
                }
                , error: function () {
                    //，并实现重传
                    var demoText = $('#demoText1');
                    demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                    demoText.find('.demo-reload').on('click', function () {
                        uploadInst.upload();
                    });
                }
            });
            var uploadInst = upload.render({
                elem: '#test2'
                , url: domain + "/tools/UploadPCImage?type=UserRule"
                 , size: 1024
                , before: function (obj) {
                    //预读本地文件示例，不支持ie8
                    obj.preview(function (index, file, result) {
                        $('#selected_ico_img').attr('src', result); //图片链接（base64）
                    });
                }
                , done: function (res) {
                    $('#selected_ico_img').attr('src', domain + res.info);
                    $('#selected_ico').val(sqlImgdomain+res.info);
                }
                , error: function () {
                    //演示失败状态，并实现重传
                    var demoText = $('#demoText2');
                    demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                    demoText.find('.demo-reload').on('click', function () {
                        uploadInst.upload();
                    });
                }
            });
            var uploadInst = upload.render({
                elem: '#test3'
                , url: domain + "/tools/UploadPCImage?type=UserRule"
                 , size: 1024
                , before: function (obj) {
                    //预读本地文件示例，不支持ie8
                    obj.preview(function (index, file, result) {
                        $('#picture_url_img').attr('src', result); //图片链接（base64）
                    });
                }
                , done: function (res) {
                    $('#picture_url_img').attr('src', domain + res.info);
                    $('#picture_url').val(sqlImgdomain+res.info);
                }
                , error: function () {
                    //演示失败状态，并实现重传
                    var demoText = $('#demoText3');
                    demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                    demoText.find('.demo-reload').on('click', function () {
                        uploadInst.upload();
                    });
                }
            });
        });
    </script>
    <script src="~/Content/js/user_rule.js"></script>
}

